﻿using _09.组合模式.Base;
using _09.组合模式.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _09.组合模式
{
    public class Client
    {
        public void Start()
        {
            Component movie1 = new Leaf("碟中谍");//叶子
            Component movie2 = new Leaf("真实的谎言");
            Component movie3 = new Leaf("第一滴血");
            Component node1 = new Composite("动作片");//枝节点
            node1.Add(movie1);
            node1.Add(movie2);
            node1.Add(movie3);

            Component movie4 = new Leaf("阿凡达");//叶子
            Component movie5 = new Leaf("盗梦空间");
            Component movie6 = new Leaf("星际穿越");
            Component movie7 = new Leaf("黑客帝国");
            Component node2 = new Composite("科幻片");//枝节点
            node2.Add(movie4);
            node2.Add(movie5);
            node2.Add(movie6);
            node2.Add(movie7);

            Component root = new Composite("电影");//根节点
            root.Add(node1);
            root.Add(node2);

            root.Display(1);//显示树形结构
        }
    }
}
